package cn.array;

/**
 * Person对象
 *
 * @author Mxb
 * @version 1.0
 * @date 2020/6/28 16:37
 */
public class Person {

    private int age;
    private String name;

    /**
     * 构造方法
     * @param age
     * @param name
     */
    public Person(int age, String name) {
        this.age = age;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    /**
     * 重写equals：
     * 比较方法
     *
     * @param obj
     * @return
     */
    @Override
    public boolean equals(Object obj) {
        Person person = (Person) obj;
        return this.age == person.age;
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();

        System.out.println("Person - finalize");
    }
}
